"Popup" Programmers Manual -------------------------- Using a popup menu in one of your programs is simple, just follow these steps... ---------- Firstly, you must include the file "popup.h" at the top of your source code using a #include statment such as... #include "popup.h" ---------- Secondly, you must include the header file that you created with the editor. This file must be included AFTER the above file, as some of the definitions in "popup.h" are used in this file. ---------- Your program must open a VDI virtual workstation, even if it does not use the VDI, as the popup system does use it. ---------- You should call the external function "PopupInit" like this... PopupInit(width,height,handle); where "width" and "height" are the screen's width and height in pixels. These values are returned from the "v_opnvwk" call in work_out[0] and work_out[1]. "handle" is the virtual workstation handle that you obtained from "v_opnvwk". So, a typical call to PopupInit may look like this... PopupInit(work_out[0]+1,work_out[1]+1,ws_handle); ---------- If you are going to replace the GEM menu bar with a popup version, then the following call is required directly after the PopupInit call. PopupRegister(menu_bar); where "menu_bar" is a character pointer to a string that contains your menu bar. For example... char *menu_bar=" Desk File Options"; ...would be an example of a menu bar. You should also define these external variables at the top of your file... extern int PopupMenu_Index; extern int PopupMenu_X; extern int PopupMenu_y; You will also need to define the variables NPLANES, MENUDISP, CH_HEIGHT, CH_WIDTH, SCR_W and SCR_H. These variables depend on the screen resolution, and the demo program shows you how to set them correctly. ---------- You may now call the main popup function like this... item=Popup(menu,buttonflag,mainflag); where... "menu" is the name of the menu that you wish to display. "buttonflag" is either 1 or 0. 1 indicates that this is a drop- down menu, of the sort that is terminated by a left button click. 0 indicates that this is a hold-down menu, of the sort that is terminated by the release of the left button. "mainflag" is either 1 or 0. 1 indicates that this call is for the main menu bar. Generally speaking, you should use 0. The demonstration file contains three functions for the management of top menus: "topmenu_choice", "topmenu_useitem" and "menu_switch". Examination of the demo source will show you how to use these functions to create a fully functioning top-line menu bar. "item" is the index number of the item that was selected by the user when he/she clicked the button. If no item was selected (the user clicked outside the menu box), or a disabled item was selected, or an item that has a sub-menu was selected then -1 is returned. Remember that you gave all your items names in the editor, so a simple "switch" statement is all that's required. So, to show a "drop-down" popup (!) menu, called "MENU_FILE", that has three named entries: "ITM_LOAD", "ITM_SAVE", and "ITM_QUIT", the following should work... switch((item=Popup(MENU_FILE,1,0))) { case ITM_LOAD: load_file(); /* your load function */ break; case ITM_SAVE: save_file(); /* your save function */ break; case ITM_QUIT: quit(); /* your quit function */ break; } Here's a hint, setting check marks in menus is very easy. Take for example the menu item "ITM_VERIFY", that is in the menu called "MENU_FILE" that is checked if the variable "verify" is 1, or not checked if it is zero. The following line of code would set the check mark appropriately. MENU_FILE[ITM_VERIFY].flags= verify ? MSELECTABLE|MCHECKED : MSELECTABLE; The constants "MSELECTABLE" and "MCHECKED" are defined in the header file "popup.h", as is the MITEM structure. ---------- Don't forget to link one of the two supplied object files with your code. The file "popup_sr.o" is for people who use the -rr AND the -w switches on the Lattice 'C' V5 compiler. The file "popup_s.o" is for people who use the -w option only. There is no support for those of you that use 32 bit integers, that means that you must use the -w option. If you do not have the Lattice 'C' V5 compiler then registration becomes a necessity. Registered users receive the source code that created the above two object files. It would be a fairly simple job for any competent programmer to make the necessary adjustments to the source code to make it compatible with other compilers, or compilers that use ridiculous 32 bit integers. ---------- If a registered user gets stuck while trying to use the popup menus, I will do my best to sort that person out. Please be aware that this cannot constitute writing your entire program for you. I can only help where I would be of genuine assistance.